<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/27
 * Time: 20:05
 */

namespace Home\Model;


use Think\Model;

class UseraddrModel extends Model
{
    /**
     * @var string
     * 用户地址
     */
    protected $tableName='useraddr';
    protected $_validate=[
       ['postname','require','请填写收件人'],
       ['useraddr','require','请填写收件地址'],
       ['postcode','require','请填写邮编'],
       ['phone','require','请填写收件人电话'],
    ];

    /**
     * @param $data
     * 用户地址添加
     */
   public function store($data){
       if($this->create($data)){
           if($data['udid']){
               $res=$this->save($data);
           }else{
               $res=$this->add($data);
           }
           return ['valid'=>1,'msg'=>'添加成功'];
       }else{
           return ['valid'=>0,'msg'=>$this->getError()];
       }

   }
}